package com.zhentao.controller;

import com.alibaba.fastjson.JSON;
import com.zhentao.common.Result;
import com.zhentao.domain.Area;
import com.zhentao.domain.City;
import com.zhentao.domain.Province;
import com.zhentao.service.AreaService;
import com.zhentao.service.CityService;
import com.zhentao.service.ProvinceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address")
@Tag(name = "获取地址")
public class SysAddressController {
    @Autowired
    private ProvinceService ProvinceService;
    @Autowired
    private CityService cityService;
    @Autowired
    private AreaService areasService;
    @GetMapping("provincelist")
    @Operation(summary = "获取省份列表")
    public Result getProvinceList() {
        return ProvinceService.getProvinceList();
    }

    @GetMapping("citylist")
    @Operation(summary = "获取城市列表")
    public Result getCitylist(Integer provinceId) {
        return cityService.getCitylist(provinceId);

    }

    @GetMapping("arealist")
    @Operation(summary = "获取地区列表")
    public Result getAreaList(Integer cityId) {
        return areasService.getAreaList(cityId);

    }
    @GetMapping("addressinfo")
    @Operation(summary = "获取具体地址信息")
    public Result<String> getAddressInfo(Integer provinceId, Integer cityId, Integer areaId) {
        return ProvinceService.getAddressInfo(provinceId,cityId,areaId);
    }
}